﻿#include "Operators3DWindowToolBar.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Component/FITKRenderWindowVTK/FITKGraph3DWindowVTK.h"
#include "GUIFrame/CentralWidget.h"
#include "GUIFrame/MainWindow.h"
#include "GUIWidget/GraphArea.h"
#include "GUIWidget/PreWindow3D.h"

namespace ModelOper
{
    bool Operators3DWindowToolBar::execGUI()
    {
        return true;
    }
    bool Operators3DWindowToolBar::execProfession()
    {
        // 获取当前窗口，尝试转换为三维窗口。
        GUI::MainWindow* mainWindow = FITKAPP->getGlobalData()->getMainWindowT<GUI::MainWindow>();
        if (mainWindow == nullptr) return nullptr;
        GUI::CentralWidget* centralWidget = mainWindow->getCentralWidget();
        if (!centralWidget)return false;
        GUI::GraphArea * graphArea = centralWidget->getGraphArea();
        if (!graphArea)return false;
        GUI::PreWindow3D* preWindow3D = dynamic_cast<GUI::PreWindow3D*>(graphArea->getCurrentSubWin());
        if (!preWindow3D)return false;
        Comp::FITKGraph3DWindowVTK* graphWindow = preWindow3D->getRenderWindow();
        if (!graphWindow || !_emitter)return false;

        //获取动作名称
        QString actionName = _emitter->objectName();
        //创建动作
        if (actionName.contains("actionViewFront"))
        {
            graphWindow->slotActionViewFrontEvent();
        }else if (actionName.contains("actionViewBack"))
        {
            graphWindow->slotActionViewBackEvent();
        }else if (actionName.contains("actionViewTop"))
        {
            graphWindow->slotActionViewTopEvent();
        }else if (actionName.contains("actionViewBottom"))
        {
            graphWindow->slotActionViewBottomEvent();
        }else if (actionName.contains("actionViewLeft"))
        {
            graphWindow->slotActionViewLeftEvent();
        }else if (actionName.contains("actionViewRight"))
        {
            graphWindow->slotActionViewRightEvent();
        }else if (actionName.contains("actionViewIso"))
        {
            graphWindow->slotActionViewIsoEvent();
        }else if (actionName.contains("actionViewAuto"))
        {
            graphWindow->slotActionViewPanEvent();
        }else if (actionName.contains("actionSaveImage"))
        {
            graphWindow->slotActionSaveImageEvent();
        }else if (actionName.contains("actionViewParallel"))
        {
            graphWindow->slotActionViewParallelEvent();
        }else if (actionName.contains("actionViewPerspective"))
        {
            graphWindow->slotActionViewPerspectiveEvent();
        }
        return true;
    }
}

